package com.wsl.sale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import java.util.HashMap;

@SpringBootApplication
@ComponentScan("com.wsl")
public class SaleApplication {
    //目前已知最好的策略是以logger所在类的名字作为logger的名称
    final public static Logger LOGGER = LoggerFactory.getLogger(SaleApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(SaleApplication.class, args);
        //自定义字段  需要在logback里面使用%X{hello}方式引用
        // MDC.put("hello","I am  MDC");
        LOGGER.error("hello I am  error");

        //打印各包路径的设置的日志级别
        //LoggerContext loggerContext =(LoggerContext)LoggerFactory.getILoggerFactory();
       // StatusPrinter.print(loggerContext);
        // 在外层判断日志级别是否设置为info级别  而不是交给logger.info()使用内部方法去判断  如果日志内容是字符串拼接的话  减少拼接次数提高效率。
        if (LOGGER.isInfoEnabled()){
            LOGGER.info("hello i am INFO");
        }
        //
       // LOGGER.isErrorEnabled();
        LOGGER.debug("Hello I am debug");
        LOGGER.info("wsl is learning logback ");
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();

        objectObjectHashMap.put("wsl",123);
    }

}
